package com.Redis.Thread;

import java.io.Serializable;
import java.util.concurrent.Callable;

import org.apache.log4j.Logger;

import com.Redis.Model.ReportData;
import com.Redis.Server.ApiReportServer;
/**
 * spring 线程池
 * @author Ren
 *
 */
public class ThreadPoolTask implements Serializable, Callable<Boolean>{
	
	private Logger logger = Logger.getLogger(this.getClass().getName());
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		
	
	//保存任务所需的数据
	private ReportData threadPoolTaskData;
	private static int consumeTaskSleepTime = 2000;
	public ThreadPoolTask(Object tasks) {
		this.threadPoolTaskData = (ReportData) tasks;
	}
	
	@Override
	public synchronized Boolean call() throws Exception {
		Boolean result = false;
		// TODO Auto-generated method stub
		 System.out.println("开始执行任务:");
		 
		 logger.info(this.threadPoolTaskData.toString());
//		 String jsonData = ApiReportServer.getInstance().getReportJsonData(this.threadPoolTaskData);
//		 logger.info("---jsonData---"+jsonData);
		 result = true;
		 		 
		 
		 
		 try {
//			 System.out.println(this.threadPoolTaskData.toString());
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
//			result = "ERROR";
		}
//		threadPoolTaskData = null;
		return result;
	}

}
